#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <chrono>

void merning(std::vector<int>& array) {
    for (int i = 0; i < array.size() - 1; i++) {
        for (int j = i + 1; j < array.size(); j++) {
            if (array[i] >= array[j]) {
                int t = array[j];
                array[j] = array[i];
                array[i] = t;
            }
        }
    }
}

int main() {
    std::ifstream file1("m1_sorted.txt");
    std::ifstream file2("m2_reverse.txt");
    std::ifstream file3("m3_shuffle.txt");

    std::vector<int> a;
    std::vector<int> b;
    std::vector<int> c;

    int num;
    while (file1 >> num) {
        a.push_back(num);
    }
    while (file2 >> num) {
        b.push_back(num);
    }
    while (file3 >> num) {
        c.push_back(num);
    }

    auto start = std::chrono::high_resolution_clock::now();
    merning(a);
    auto finish = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double, std::milli> elapsed = finish - start;
    std::cout << "m1_sorted " << round(elapsed.count()) << " milliseconds" << std::endl;

    start = std::chrono::high_resolution_clock::now();
    merning(b);
    finish = std::chrono::high_resolution_clock::now();
    elapsed = finish - start;
    std::cout << "m2_reverse " << round(elapsed.count()) << " milliseconds" << std::endl;

    start = std::chrono::high_resolution_clock::now();
    merning(c);
    finish = std::chrono::high_resolution_clock::now();
    elapsed = finish - start;
    std::cout << "m3_shuffle " << round(elapsed.count()) << " milliseconds" << std::endl;

    return 0;
}

